package com.itcast.gateway.handler;

import org.springframework.http.MediaType;
import org.springframework.lang.NonNull;
import org.springframework.stereotype.Component;
import org.springframework.web.reactive.function.BodyInserters;
import org.springframework.web.reactive.function.server.HandlerFunction;
import org.springframework.web.reactive.function.server.ServerRequest;
import org.springframework.web.reactive.function.server.ServerResponse;
import reactor.core.publisher.Mono;
import springfox.documentation.swagger.web.UiConfigurationBuilder;

/**
 * @author zheng.zhang
 * Description SwaggerUiHandler
 * @date 2020/9/11 11:37
 * Version 1.0
 */
@Component
public class SwaggerUiHandler implements HandlerFunction<ServerResponse> {
    @Override
    @NonNull
    public Mono<ServerResponse> handle(@NonNull ServerRequest request) {
        return ServerResponse.ok()
                .contentType(MediaType.APPLICATION_JSON)
                .body(BodyInserters.fromValue(UiConfigurationBuilder.builder().build()));
    }
}
